package com.darrendb.utils {
	public class NumUtils {
		public function NumUtils() {
			
		}
		private static function randomBetween(p_min:Number, p_max:Number, p_isInt:Boolean = true):Number {
			/*
			USAGE:
				var minValue:Number = 3;
				var maxValue:Number = 27;
				var rvInteger:Number = randomBetween(minValue, maxValue, true);
				var rvNotInteger:Number = randomBetween(minValue, maxValue, false);
				trace (rvInteger); // output: 15
				trace (rvNotInteger); // output: 25.71537097916007
			*/
			return (p_isInt) ? 
				( Math.floor( Math.random() * ( p_max - p_min ) ) + p_min ) : 
				( Math.random() * (p_max - p_min) + p_min );
		}
		public static function truncateNumber (p_value:Number, p_decimalPlace:uint, p_rounded:Boolean = true):Number {
			/*
			USAGE:
				var value:Number = 22.239030607;
				var vRoundedTo2ndPlace:Number = truncateNumber(value, 2, true);
				var vNotRoundedTo2ndPlace:Number = truncateNumber(value, 2, false);
				trace (vRoundedTo2ndPlace); // output: 22.24
				trace (vNotRoundedTo2ndPlace); // output: 22.23
			*/
			return ( p_rounded ) ? 
				( Math.round( ( p_value * 100 ) ) ) / ( Math.pow( 10, p_decimalPlace ) ) :
				( Math.floor( p_value * 100 )  ) / ( Math.pow( 10, p_decimalPlace ) );
		}

	}
}